package com.tianyang.yukuaifu.business.trade.adapter;

import android.text.TextUtils;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tianyang.yukuaifu.R;
import com.tianyang.yukuaifu.business.trade.bean.MerchantAchieveOutput;
import com.tianyang.yukuaifu.utils.VerifyUtil;

import java.util.ArrayList;

/**
 * Description：商户业绩
 * Created by xyj on 2024/3/25
 */
public class MerchantAchieveAdapter extends BaseQuickAdapter<MerchantAchieveOutput, BaseViewHolder> {

    private boolean isSubMerchant;

    public MerchantAchieveAdapter(int layout, boolean isSubMerchant) {
        super(layout, new ArrayList<>());
        this.isSubMerchant = isSubMerchant;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, MerchantAchieveOutput item) {
        if (item != null) {
            if (isSubMerchant) {
                helper.setText(R.id.nameTv, item.getAgentName() + "团队")
                        .setText(R.id.subTradeAmountTv, VerifyUtil.decimalFormat(item.getSubTradeAmount()))
                        .setText(R.id.subProfitTv, VerifyUtil.decimalFormat(item.getSubProfit()))
                        .setText(R.id.subAgentNumberTv, TextUtils.isEmpty(item.getSubAgentNumber()) ? "0" : item.getSubAgentNumber())
                        .setText(R.id.subMerchantNumberTv, TextUtils.isEmpty(item.getSubMerchantNumber()) ? "0" : item.getSubMerchantNumber());

            } else {
                helper.setText(R.id.nameTv, item.getName() + "（" + item.getMchName() + "）")
                        .setText(R.id.totalAmountTv, VerifyUtil.decimalFormat(item.getTotalAmount()))
                        .setText(R.id.tradeCountTv, TextUtils.isEmpty(item.getTotalAmount()) ? "0" : item.getTotalAmount())
                        .setText(R.id.totalProfitTv, VerifyUtil.decimalFormat(item.getTotalProfit()));
            }
        }
    }
}
